﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GGEditor.API;
using GGEditor.API.Plugins;

namespace GGEditor.Core.UI
{
	[XmlNodeObjectFactory(Name = "Pad")]
	public class PadFactory : NodeFactory<Control>
	{
		public override object Build(IPluginNode pluginNode, IDictionary<string, string> attributes)
		{
			Control content = base.Build(pluginNode, attributes) as Control;

			WindowParameters.DockState dockState = (attributes.ContainsKey("dock")) ?
				(WindowParameters.DockState)Enum.Parse(
					typeof(WindowParameters.DockState),
					attributes["dock"], true) :
					WindowParameters.DockState.Right;

			return new WindowParameters()
			{
				Content = content,
				IsDocument = false,
				Text = attributes["text"],
				Dock = dockState
			};
		}
	}
}
